<script lang="ts" setup>
import { registry } from "../../../api/";
const router = useRouter();
const form = reactive({
  email: "",
  password: "",
  code: "",
});
provide("email", form.email);
const registryUser = async () => {
  const data = await registry(form);
  if (data.data) {
    console.log(data);
    ElMessage({
      message: "注册成功",
      type: "success",
    });
    router.push("/login");
  } else {
    console.log("数据获取失败");
    ElMessage({
      message: "注册失败",
      type: "error",
    });
  }
};
</script>
<template>
  <div class="flex justify-center h-[100vh] items-center flex-col">
    <div class="mb-5">注册页面</div>
    <el-form :model="form" label-width="auto" style="max-width: 600px">
      <el-form-item label="邮箱地址">
        <el-input v-model="form.email" placeholder="请输入邮箱地址" />
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item label="验证码">
        <Code />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="registryUser" class="m-auto"
          >注册</el-button
        >
        <div class="ml-20">
          已注册,去
          <router-link to="/login"> 登录 </router-link>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>
